package model;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class SpringBeansFactory {
    
    private static SpringBeansFactory Instance = new SpringBeansFactory();
    private ApplicationContext ctx;
    
    private SpringBeansFactory() {
        ctx = new FileSystemXmlApplicationContext("spring.xml");
    }
    
    public static SpringBeansFactory getInstance() {
        return Instance;
    }

    public IAddressList createAddressList() {
        return (IAddressList)ctx.getBean("AddressList");
    }
    
    public IPostalAddress createPostalAddress() {
        return (IPostalAddress)ctx.getBean("PostalAddress");
    }
    
    public IEmailonlyAddress createEmailonlyAddress() {
        return (IEmailonlyAddress)ctx.getBean("EmailonlyAddress");
    }
    
}